// #ifndef _TINYXML2_H_
#include"./tinyxml2-master/tinyxml2.h"
// #endif
#include"./tinyxml2-master/tinyxml2.cpp"
#include"./myClass/shape_pro.cpp"
#include<iostream>
#include<vector>

using namespace std;
using namespace tinyxml2;

ShapePro* spPrReader(tinyxml2::XMLElement *node){
    //spPr spPr0;
    ShapePro *my_ShapePro = new ShapePro;

    if(node->FirstChildElement("p:spPr")){

        tinyxml2::XMLElement *spPrNode = node->FirstChildElement("p:spPr"); 
        
        const tinyxml2::XMLAttribute* off_x = spPrNode->FirstChildElement("a:xfrm")
                                                ->FirstChildElement("a:off")->FindAttribute("x");
        TransForm2D my_trans2d = my_ShapePro->GetTrans2d();
        my_trans2d.SetX(atoi(off_x->Value()));
        

        const tinyxml2::XMLAttribute* off_y = spPrNode->FirstChildElement("a:xfrm")
                                                ->FirstChildElement("a:off")->FindAttribute("y");
        my_trans2d.SetY(atoi(off_y->Value()));
        
        const tinyxml2::XMLAttribute* ext_cx = spPrNode->FirstChildElement("a:xfrm")
                                                ->FirstChildElement("a:ext")->FindAttribute("cx");
        my_trans2d.SetCX(atoi(ext_cx->Value()));
        
        const tinyxml2::XMLAttribute* ext_cy = spPrNode->FirstChildElement("a:xfrm")
                                                ->FirstChildElement("a:ext")->FindAttribute("cy");
        my_trans2d.SetCY(atoi(ext_cy->Value()));
        my_ShapePro->SetTrans2d(my_trans2d);

        if(spPrNode->FirstChildElement("a:prstGeom"))
        {
            const tinyxml2::XMLAttribute* prst = spPrNode->FirstChildElement("a:prstGeom")
                                                ->FindAttribute("prst");
            PrstGeometry2D my_PrstGeom = my_ShapePro->GetPrst2d();
            my_PrstGeom.SetPrstGeometry2D(prst->Value());
            my_ShapePro->SetPrst2d(my_PrstGeom);        
        }            

        if(spPrNode->FirstChildElement("a:prstGeom")
                    ->FirstChildElement("a:avLst")->FirstChildElement("a:gd")){
            const tinyxml2::XMLAttribute *gd_name = spPrNode->FirstChildElement("a:prstGeom")
                                                        ->FirstChildElement("a:avLst")
                                                        ->FirstChildElement("a:gd")
                                                        ->FindAttribute("name");
            PrstGeometry2D my_PrstGeom1 = my_ShapePro->GetPrst2d();
            my_PrstGeom1.SetPrstGeometry2D_name(gd_name->Value());

            const tinyxml2::XMLAttribute *gd_fmla = spPrNode->FirstChildElement("a:prstGeom")
                                                        ->FirstChildElement("a:avLst")
                                                        ->FirstChildElement("a:gd")
                                                        ->FindAttribute("fmla");
            my_PrstGeom1.SetPrstGeometry2D_fmla(gd_fmla->Value());
            my_ShapePro->SetPrst2d(my_PrstGeom1);
        }
        
                              
        if(spPrNode->FirstChildElement("a:solidFill"))
        {
            const tinyxml2::XMLAttribute* val = spPrNode->FirstChildElement("a:solidFill")
                                                ->FirstChildElement("a:schemeClr")->FindAttribute("val");
            // m_spPr->m_solidFill.val = val->Value();
            SolidFill my_SolidFill = my_ShapePro->GetFill();
            my_SolidFill.SetFill(val->Value());
            my_ShapePro->SetFill(my_SolidFill);  
        }
        
        if(spPrNode->FirstChildElement("a:ln")){
            const tinyxml2::XMLAttribute* type = spPrNode->FirstChildElement("a:ln")
                                                ->FirstChildElement("a:tailEnd")->FindAttribute("type");
            // m_spPr->m_ln.type = type->Value();
            LineType my_LineType = my_ShapePro->GetLine();
            my_LineType.SetLineType(type->Value());
            my_ShapePro->SetLine(my_LineType);  
        }
    }
    return my_ShapePro;
}